| Conditions | 5 | 
| Paths | 7 | 
| Total Lines | 54 | 
| Code Lines | 37 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 1 | ||
| Bugs | 0 | Features | 0 | 
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | $(document).ready(function () { | 
            ||
| 2 |     function getCurrentDateStr() { | 
            ||
| 3 | var month = d.getMonth() + 1;  | 
            ||
| 4 | var day = d.getDate();  | 
            ||
| 5 | return d.getFullYear() + '-' +  | 
            ||
| 6 | (month < 10 ? '0' : '') + month + '-' +  | 
            ||
| 7 | (day < 10 ? '0' : '') + day;  | 
            ||
| 8 | }  | 
            ||
| 9 | |||
| 10 |     function getCurrentTimeStr() { | 
            ||
| 11 | return d.getHours() + ":" + d.getMinutes();  | 
            ||
| 12 | }  | 
            ||
| 13 | |||
| 14 |     function scrollToNearReport() { | 
            ||
| 15 | var scrollTo = null;  | 
            ||
| 16 | var current_report = null;  | 
            ||
| 17 | var prev_report = null;  | 
            ||
| 18 | var now_time = getCurrentTimeStr();  | 
            ||
| 19 | |||
| 20 |         $('.program-body__td--time').each(function (index, value) { | 
            ||
| 21 |             if (current_report !== null) { | 
            ||
| 22 | prev_report = current_report;  | 
            ||
| 23 | }  | 
            ||
| 24 | current_report = $(this);  | 
            ||
| 25 |             if (now_time < current_report.text()) { | 
            ||
| 26 |                 if (prev_report !== null) { | 
            ||
| 27 | scrollTo = prev_report;  | 
            ||
| 28 |                 } else { | 
            ||
| 29 | scrollTo = current_report;  | 
            ||
| 30 | }  | 
            ||
| 31 | return false;  | 
            ||
| 32 | }  | 
            ||
| 33 | });  | 
            ||
| 34 |         if (scrollTo !== null) { | 
            ||
| 35 |             $('body,html').animate({ | 
            ||
| 36 | scrollTop: scrollTo.offset().top - 125  | 
            ||
| 37 | }, 600);  | 
            ||
| 38 | }  | 
            ||
| 39 | }  | 
            ||
| 40 | |||
| 41 |     var event_header_date_element = $('.event-header__date'); | 
            ||
| 42 |     if (event_header_date_element.length) { | 
            ||
| 43 | var d = new Date();  | 
            ||
| 44 | var now_date = getCurrentDateStr();  | 
            ||
| 45 |         var event_date = event_header_date_element.attr('datetime'); | 
            ||
| 46 | |||
| 47 |         if ('scrollRestoration' in history) { | 
            ||
| 48 | history.scrollRestoration = event_date === now_date ? 'manual' : 'auto';  | 
            ||
| 49 | }  | 
            ||
| 50 |         if (event_date === now_date) { | 
            ||
| 51 | scrollToNearReport();  | 
            ||
| 52 | }  | 
            ||
| 53 | }  | 
            ||
| 54 | });  | 
            
This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.